﻿//Created by Action Script Viewer - http://www.buraks.com/asv
package org.aswing.util {

    public class StringUtils {

        public static function isString(_arg1):Boolean{
            return ((_arg1 is String));
        }
        public static function castString(_arg1):String{
            return ((_arg1 as String));
        }
        public static function replace(_arg1:String, _arg2:String, _arg3:String):String{
            return (_arg1.split(_arg2).join(_arg3));
        }
        public static function trim(_arg1:String):String{
            return (trimLeft(trimRight(_arg1)));
        }
        public static function trimLeft(_arg1:String):String{
            var _local2:int;
            var _local3 = "";
            var _local4:int;
            while (_local4 < _arg1.length) {
                _local3 = _arg1.charAt(_local4);
                if (_local3 != " "){
                    _local2 = _local4;
                    break;
                };
                _local4++;
            };
            return (_arg1.substr(_local2));
        }
        public static function trimRight(_arg1:String):String{
            var _local2:int = (_arg1.length - 1);
            var _local3 = "";
            var _local4:int = (_arg1.length - 1);
            while (_local4 >= 0) {
                _local3 = _arg1.charAt(_local4);
                if (_local3 != " "){
                    _local2 = _local4;
                    break;
                };
                _local4--;
            };
            return (_arg1.substring(0, (_local2 + 1)));
        }
        public static function getCharsArray(_arg1:String, _arg2:Boolean):Array{
            var _local3:String = _arg1;
            if (_arg2 == false){
                _local3 = trim(_arg1);
            };
            return (_local3.split(""));
        }
        public static function startsWith(_arg1:String, _arg2:String):Boolean{
            return ((_arg1.indexOf(_arg2) == 0));
        }
        public static function endsWith(_arg1:String, _arg2:String):Boolean{
            return ((_arg1.lastIndexOf(_arg2) == (_arg1.length - _arg2.length)));
        }
        public static function isLetter(_arg1:String):Boolean{
            var _local3:uint;
            if ((((_arg1 == null)) || ((_arg1 == "")))){
                return (false);
            };
            var _local2:int;
            while (_local2 < _arg1.length) {
                _local3 = _arg1.charCodeAt(_local2);
                if ((((((_local3 < 65)) || ((_local3 > 122)))) || ((((_local3 > 90)) && ((_local3 < 97)))))){
                    return (false);
                };
                _local2++;
            };
            return (true);
        }

    }
}//package org.aswing.util 
